home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume6 / reminders < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  24.3 KB

  1. Subject: v06i085:  A Personal Reminder system (reminders)
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: ihnp4!allegra!novavax!don (Don Joslyn)
  6. Mod.sources: Volume 6, Issue 85
  7. Archive-name: reminders
  8.  
  9. [  Some sites will have to tweak the Makefile, as "install" is not a
  10.    standard program throughout the Unix world.  I just used strip,
  11.    followed by cp.  --r$ ]
  12. --------------------CUT HERE--------------------
  13. #! /bin/sh
  14. # This is a shell archive, meaning:
  15. # 1. Remove everything above the #! /bin/sh line.
  16. # 2. Save the resulting text in a file.
  17. # 3. Execute the file with /bin/sh (not csh) to create:
  18. #    README
  19. #    Makefile
  20. #    rs.c
  21. #    rs.1
  22. # This archive created: Thu Jul  3 15:58:03 1986
  23. # By:    Don Joslyn (Nova University, Fort Lauderdale, Florida)
  24. export PATH; PATH=/bin:/usr/bin:$PATH
  25. echo shar: "extracting 'README'" '(1568 characters)'
  26. if test -f 'README'
  27. then
  28.     echo shar: "will not over-write existing file 'README'"
  29. else
  30. sed 's/^XX//' << \SHAR_EOF > 'README'
  31. XXrs - a reminder system, by:
  32. XX
  33. XX    Don Joslyn, Manager
  34. XX    Nova University Computer Center
  35. XX    3301 College Avenue
  36. XX    Fort Lauderdale, Florida 33314
  37. XX    (305) 475-7678
  38. XX    ...{codas, allegra, ucf-cs}!novavax!don
  39. XX
  40. XXThis directory contains the source and manual entry for the rs program.
  41. XXSee the manual entry for more information on the use of rs.
  42. XX
  43. XXTo Install:
  44. XX
  45. XX1)    Look at rs.c and change any #defines needed.
  46. XX    Defaults:
  47. XX
  48. XX        CALENDAR  "/calendar"        users calendar file.
  49. XX        RSFILE      "/.reminders"        users reminder file.
  50. XX        RSNOTES      "/.rsnotes"        users notes    file.
  51. XX
  52. XX        LPR        "/usr/ucb/lpr"    location of lpr command.
  53. XX        EDITOR        "/usr/ucb/vi"    default editor.
  54. XX
  55. XX        MAXLINES    500        Max. number of lines (reminders)
  56. XX        MAXLEN        256        Max. len of a single line.
  57. XX
  58. XX    If your /tmp directory is somewhere else, change rstmp.
  59. XX    Default:    char rstmp[] = "/tmp/rsXXXXX"
  60. XX
  61. XX2)    Edit the Makefile.
  62. XX
  63. XX    Change target directory for the rs executable and manual entry
  64. XX    if you wish.
  65. XX
  66. XX    Defaults:
  67. XX
  68. XX        DEST  = /usr/local        rs program >> /usr/local
  69. XX        MDEST = /usr/man/manl        rs manual  >> /usr/man/manl
  70. XX
  71. XX    If you have something other than termcap, make the change to LIBS.
  72. XX
  73. XX    If you are not a BSD site, take '-DBSD' out of the Makefile so that
  74. XX    strnchr and <string.h> will be used in place of rindex and <strings.h>
  75. XX
  76. XX3)    Run 'make install' which will make and install the executables and the
  77. XX    manual entries.
  78. XX    If you want to compile the rs program in the current directory,
  79. XX    run 'make program'.
  80. XX
  81. XX------------------
  82. XXMail questions to:
  83. XX
  84. XX    ...{codas, allegra, ucf-cs}!novavax!don
  85. XX
  86. XXThe main purpose of the rs command, is to make remembering easy!
  87. SHAR_EOF
  88. if test 1568 -ne "`wc -c < 'README'`"
  89. then
  90.     echo shar: "error transmitting 'README'" '(should have been 1568 characters)'
  91. fi
  92. fi
  93. echo shar: "extracting 'Makefile'" '(513 characters)'
  94. if test -f 'Makefile'
  95. then
  96.     echo shar: "will not over-write existing file 'Makefile'"
  97. else
  98. sed 's/^XX//' << \SHAR_EOF > 'Makefile'
  99. XXDEST          = /usr/local
  100. XX
  101. XXMDEST          = /usr/man/manl/rs.l
  102. XX
  103. XXLDFLAGS          = -DBSD -O -w
  104. XX
  105. XXLIBS          = -ltermcap
  106. XX
  107. XXLINKER          = cc
  108. XX
  109. XXMANUAL          = rs.1
  110. XX
  111. XXPROGRAM          = rs
  112. XX
  113. XXSRCS          = rs.c
  114. XX
  115. XXall:        $(PROGRAM)
  116. XX
  117. XX$(PROGRAM):     
  118. XX        @echo -n "Loading rs ..."
  119. XX        @$(LINKER) $(LDFLAGS) $(SRCS) $(LIBS) -o $(PROGRAM)
  120. XX        @echo "done."
  121. XX
  122. XXinstall:    $(PROGRAM)
  123. XX        @echo Installing $(PROGRAM) in $(DEST)
  124. XX        @install -s $(PROGRAM) $(DEST)
  125. XX        @echo Installing manual in $(MDEST)
  126. XX        @cp $(MANUAL) $(MDEST)
  127. XX
  128. XXprogram:        $(PROGRAM)
  129. SHAR_EOF
  130. if test 513 -ne "`wc -c < 'Makefile'`"
  131. then
  132.     echo shar: "error transmitting 'Makefile'" '(should have been 513 characters)'
  133. fi
  134. fi
  135. echo shar: "extracting 'rs.c'" '(13652 characters)'
  136. if test -f 'rs.c'
  137. then
  138.     echo shar: "will not over-write existing file 'rs.c'"
  139. else
  140. sed 's/^XX//' << \SHAR_EOF > 'rs.c'
  141. XXstatic char rcsid[] = "$Header: rs.c,v 3.3 86/07/03 14:24:34 don Exp $";
  142. XX
  143. XX/* $Log:    rs.c,v $
  144. XX * Revision 3.3  86/07/03  14:24:34  don
  145. XX * 1.  MAX_LINE (# columns on a line) now defined by termcap entry for TERM.
  146. XX * 2.  Misc. Optimizations.
  147. XX * 3.  Reminders can now be "marked", by appending ^G to reminder, to have
  148. XX *     reminder highlighted during display.  "Highlight" options can be defined
  149. XX *     in the RSINIT environment variable.
  150. XX *     U - Underscore,  B - Bold,  S - Asterisk. (Default is standout)
  151. XX *     I - Ignore termcap entry.
  152. XX * 
  153. XX * Revision 3.2  85/08/26  14:55:42  don
  154. XX * Adding Mike's enhancements.  Thanks Mike! :-)
  155. XX * Revision 3.2 & 3.3 by Mike Spitzer @ (pur-ee!mjs)
  156. XX * 
  157. XX * Revision 3.2  85/08/05  13:10:52  mjs
  158. XX * -added new print_line which doesn't barf on long words
  159. XX * -added #define for place to break up lines(MAX_LINE)
  160. XX * -print_line is always called now, test for strlen(line) < MAX_LINE
  161. XX *  is now made there.
  162. XX * 
  163. XX *     MIke Spitzer
  164. XX *     pur-ee!mjs
  165. XX * 
  166. XX * Revision 3.1  85/07/26  20:48:06  mjs
  167. XX * "rs" now recognizes the $EDITOR variable.  "vi" will be used if 
  168. XX * $EDITOR is undefined.
  169. XX * 
  170. XX * added "-e" flag... does the same thing as "-v"
  171. XX * 
  172. XX * -mjs
  173. XX * 
  174. XX * Revision 2.2  85/02/25  10:35:48  don
  175. XX * 1.  Optimized kill and line wrap routines.
  176. XX * 2.  Added defines for LPR & VI.
  177. XX * 3.  Added more RSINIT options. (A & D)
  178. XX * 4.  Deleted add_calendar routine, now uses add_reminders.
  179. XX * 5.  Added comments.
  180. XX * 
  181. XX * Revision 2.1  85/01/28  17:03:56  don
  182. XX * 1. Added new notes file - .rsnotes | command rs -n
  183. XX * 2. Added new alternate file - user defined via setenv RSALT | command rs -A
  184. XX * 3. Added environment variable RSINIT.
  185. XX *    setenv RSINIT 'ad' | a = display after add | d = display after delete.
  186. XX * 4. Lines may now be 256 char. long.
  187. XX * 5. Long lines will automatically wrap like 'vi'.
  188. XX * 6. Added search command. | rs -s 'search string'
  189. XX * 7. Help deleted, replaced with 'usage' message.
  190. XX * 8. Misc. optimizations.
  191. XX * 
  192. XX * Revision 1.3  85/01/15  09:17:57  don
  193. XX * 1. Added $Log line for RCS.
  194. XX * 2. Fixed help message.
  195. XX * 3. Coded in range deletion.
  196. XX *  */
  197. XX
  198. XX/*    Program    written by:    Don Joslyn
  199. XX *                Nova University Computer Center
  200. XX *                3301 College Avenue
  201. XX *                Fort Lauderdale, Florida 33314
  202. XX *                (305) 475-7630 (novavax!don)
  203. XX *
  204. XX *    Notice:  No Copyright. 
  205. XX *
  206. XX*/
  207. XX
  208. XX#include    <stdio.h>
  209. XX#include    <ctype.h>
  210. XX#ifdef    BSD
  211. XX#include    <strings.h>
  212. XX#else
  213. XX#include    <string.h>
  214. XX#define        rindex    strnchr
  215. XX#endif    BSD
  216. XX
  217. XX#define        MAXLEN   256    /* Max. Length of a single line     */
  218. XX#define        MAXLINES 500    /* Max. number of lines (reminders) */
  219. XX
  220. XX#define        CALENDAR "/calendar"    /* calendar file */
  221. XX#define        RSFILE     "/.reminders"    /* reminder file */
  222. XX#define        RSNOTES  "/.rsnotes"    /* notes    file */
  223. XX
  224. XX#define        LPR    "/usr/ucb/lpr"    /* location of lpr */
  225. XX#define        EDITOR    "/usr/ucb/vi"     /* default editor  */
  226. XX
  227. XX/*#define        BIGHELP    /* Define if you want verbose help message */
  228. XX
  229. XXFILE    *fp,
  230. XX    *fptmp;
  231. XX
  232. XXchar    fname[128],        /* Filename tmp */
  233. XX    on[32],            /* string used to turn "mark" on  */
  234. XX    off[32],        /* string used to turn "mark" off */
  235. XX    buff[1024],        /* Holds termcap entry for TERM */
  236. XX    s[MAXLEN],        /* Tmp string and line storage */
  237. XX    sstr[80],        /* Search string */
  238. XX    cmd[256];        /* cmd for system call */
  239. XX
  240. XXchar    *a,
  241. XX    *editor,        /* Hold for EDITOR environment variable */
  242. XX    *entity = "Reminders",    /* Entity working on */
  243. XX    *env,            /* Hold for RSINIT environment variable */
  244. XX    *fun,            /* Used in arg processing */
  245. XX    *mark_on  = "so",    /* Default mark is Standout mode */
  246. XX    *mark_off = "se";    /* Standout end */
  247. XX    
  248. XX
  249. XXchar    *getenv(),
  250. XX    *malloc(),
  251. XX    *mktemp();
  252. XX
  253. XXchar    rstmp[]= "/tmp/rsXXXXXX";    /* name of temp. file during delete */
  254. XX
  255. XXint    adisplay = 0,    /* display reminders after additions (default = no) */
  256. XX    ddisplay = 0,    /* display reminders after deletions (default = no) */
  257. XX    Adisplay = 0,    /* display notes/alt after additions (default = no) */
  258. XX    Ddisplay = 0,    /* display notes/alt after deletions (default = no) */
  259. XX    columns = 80,    /* Number of columns in a line. */
  260. XX    len      = 0,    /* Length of line */
  261. XX    mark     = 0,    /* Mark the line (High Priority) */
  262. XX    tcap     = 1,    /* Read Termcap stuff. */
  263. XX    tcapok   = 0,    /* TERM found in Termcap file. */
  264. XX    rem_work = 1,    /* working on reminder file by default */
  265. XX    search   = 0,    /* search option seen on command line */
  266. XX    status;        /* Hold status returned by sys calls and such */
  267. XX
  268. XXmain(argc, argv)
  269. XXint    argc;
  270. XXchar    *argv[];
  271. XX{ 
  272. XX
  273. XX/* Get RSINIT environment variable to find options desired */
  274. XX
  275. XXenv = getenv("RSINIT");
  276. XX
  277. XXwhile (*env) {
  278. XX    switch(*env++) {
  279. XX        case 'a' : adisplay++; break;
  280. XX        case 'd' : ddisplay++; break;
  281. XX        case 'A' : Adisplay++; break;
  282. XX        case 'D' : Ddisplay++; break;
  283. XX        case 'I' : tcap = 0;   break;
  284. XX        case 'U' :
  285. XX            mark_on  = "us";
  286. XX            mark_off = "ue";
  287. XX            break;
  288. XX        case 'B' :
  289. XX            mark_on  = "bo";
  290. XX            mark_off = "be";
  291. XX            break;
  292. XX        case 'S' :
  293. XX            mark_on  = "ss";
  294. XX            mark_off = "ss";
  295. XX            break;
  296. XX    }
  297. XX}
  298. XX
  299. XX
  300. XX/* Get users HOME directory and construct default name for reminder file */
  301. XX
  302. XXsprintf(fname, "%s%s", getenv("HOME"), RSFILE);
  303. XX
  304. XX/* Find out what the user wants to do */
  305. XX
  306. XXwhile ( --argc > 0 && (*++argv)[0] == '-')
  307. XX    for (fun = argv[0]+1; *fun != '\0'; fun++)
  308. XX        switch(*fun) {
  309. XX        case 'A' :    /* Work on Alternate reminder file */
  310. XX            env = getenv("RSALT");
  311. XX            if (!env)
  312. XX                env = "phone_numbers";
  313. XX
  314. XX            sprintf(fname, "%s/.%s", getenv("HOME"), env);
  315. XX            entity = env;
  316. XX            if (islower(entity[0]))
  317. XX                entity[0] = toupper(entity[0]);
  318. XX            rem_work = 0;
  319. XX            break;
  320. XX
  321. XX        case 'a' :    /* Add reminder(s)/note(s)/alternate(s) */
  322. XX            add_reminder();
  323. XX            exit(0);
  324. XX
  325. XX        case 'c' :    /* Add entries to calendar file */
  326. XX            sprintf(fname, "%s%s", getenv("HOME"), CALENDAR);
  327. XX            entity = "Calendar commands";
  328. XX            rem_work = 0;
  329. XX            add_reminder();
  330. XX            exit(0);
  331. XX
  332. XX        case 'd' :    /* Delete reminder(s)/note(s)/alternate(s) */
  333. XX            delete_reminder(argc, argv);
  334. XX            exit(0);
  335. XX
  336. XX        case 'k' :    /* Kill all reminders/notes/alternates */
  337. XX            if ( unlink(fname) == 0) {
  338. XX                printf("%s killed.\n", entity);
  339. XX            }
  340. XX            exit(0);
  341. XX
  342. XX        case 'n' :    /* Work on notes file */
  343. XX            sprintf(fname, "%s%s", getenv("HOME"), RSNOTES);
  344. XX            entity = "Notes";
  345. XX            rem_work = 0;
  346. XX            break;
  347. XX
  348. XX        case 'p' :    /* print reminders/notes/alternates */
  349. XX            sprintf(cmd, "%s %s", LPR, fname);
  350. XX            status = system(cmd);
  351. XX
  352. XX            if (status == 0) {
  353. XX                printf("%s will be printed.\n", entity);
  354. XX                exit(0);
  355. XX            }
  356. XX            else {
  357. XX                printf("%s can't be printed, sorry\n", entity);
  358. XX                exit(1);
  359. XX            }
  360. XX
  361. XX        case 's' :    /* search for string in reminders/notes/alts */
  362. XX            argc--;
  363. XX            argv++;
  364. XX            sprintf(sstr, "%s", argv[0]);
  365. XX            search++;
  366. XX            break;
  367. XX        case 'e' : /* -e and -v are equivilent */
  368. XX        case 'v' : /* Edit reminders/notes/alternates with editor */
  369. XX            editor = getenv("EDITOR");
  370. XX            if (!editor)
  371. XX                editor = EDITOR;
  372. XX            sprintf(cmd, "%s %s",editor,fname);
  373. XX            system(cmd);
  374. XX            exit(0);
  375. XX        default:    /* Give em some help */
  376. XX#ifndef    BIGHELP
  377. XX            printf("Usage: rs [ -Aaceknpv ] [ -s search_string ] [ -d # ] [ -d #-# ]\n");
  378. XX            printf("For additional information type:  man rs\n");
  379. XX#else
  380. XX            /* You can enable this stuff if you want! */
  381. XX            printf("Reminder Service commands:\n\n");
  382. XX            printf("-A\tWork on Alternate reminder file.\n");
  383. XX            printf("-a\tAdd reminder(s)/note(s)/Alt(s).\n");
  384. XX            printf("-c\tAdd line(s) to the calendar file.\n");
  385. XX            printf("-d\tDelete reminder(s)/note(s)/Alt(s).\n");
  386. XX            printf("-k\tKill all reminders/notes/Alternate.\n");
  387. XX            printf("-n\tWork on notes.\n");
  388. XX            printf("-p\tPrint reminders/notes/Alternates.\n");
  389. XX            printf("-s\tSearch for string.\n");
  390. XX            printf("-e\tEdit reminders/notes/Alt.\n\n");
  391. XX            printf("rs with no option will display reminders.\n");
  392. XX            printf("SEE ALSO rs(1)\n");
  393. XX#endif    BIGHELP
  394. XX            exit(0);
  395. XX        }
  396. XX
  397. XXprint_reminders();
  398. XX
  399. XX}
  400. XX
  401. XX
  402. XX/* ADD REMINDERS */
  403. XX/* This routine uses cat to add lines to the reminder/note/alternate file */
  404. XX/* If you don't like it, add your own getline routine! */
  405. XX
  406. XXadd_reminder()
  407. XX{
  408. XX    printf("Enter %s then ^d to exit:\n", entity);
  409. XX
  410. XX    sprintf(cmd, "%s %s","/bin/cat >>",fname);
  411. XX    system(cmd);
  412. XX    if ( (adisplay && rem_work) || (Adisplay && !rem_work) )
  413. XX        print_reminders();
  414. XX}
  415. XX
  416. XX
  417. XX/* DELETE REMINDERS/NOTES/ALTERNATES */
  418. XX
  419. XXdelete_reminder(argc, argv)
  420. XX    int    argc;
  421. XX    char    *argv[];
  422. XX{
  423. XX    int    begin,
  424. XX        end,
  425. XX        delete_line[MAXLINES];
  426. XX
  427. XX    char    a[4], b[4];
  428. XX
  429. XX    register int    i        = 0,
  430. XX            j        = 0,
  431. XX            deleted     = 0,
  432. XX            line_number = 0,
  433. XX            printed     = 0;
  434. XX
  435. XX    argc--, argv++;
  436. XX    for (;argc > 0; argc--, argv++) {
  437. XX        if (alldigits(*argv)) {
  438. XX            delete_line[atoi(*argv)] = 1;
  439. XX        }
  440. XX        else {
  441. XX            i = rindex(*argv, '-');
  442. XX            sscanf(i+1, "%s", b );
  443. XX            j = ( strlen(*argv) - strlen(b) ) - 1;
  444. XX            strncpy(a, *argv, j);
  445. XX            a[j]='\0';
  446. XX            begin = atoi(a);
  447. XX            end   = atoi(b);
  448. XX
  449. XX            if (begin < end) {
  450. XX                for (j = begin ; j < end+1 ; j++)
  451. XX                    delete_line[j] = 1;
  452. XX            }
  453. XX            else {
  454. XX                printf("Illegal range specified.\n");
  455. XX                exit(1);
  456. XX            }
  457. XX        }
  458. XX    }
  459. XX
  460. XX    mktemp(rstmp);
  461. XX    if ((fptmp = fopen(rstmp,"w")) == NULL) {
  462. XX        print_open_error_exit(rstmp);
  463. XX    }
  464. XX
  465. XX    if ((fp = fopen(fname,"r")) == NULL) {
  466. XX        print_open_error_exit(fname);
  467. XX    }
  468. XX
  469. XX    while (getline(s, MAXLEN) > 0) {
  470. XX        if (delete_line[++line_number] != 1) {
  471. XX            fprintf(fptmp,"%s",s);
  472. XX            printed++;
  473. XX        }
  474. XX        else {
  475. XX            deleted++;
  476. XX        }
  477. XX    }
  478. XX
  479. XX    fclose(fp);
  480. XX    fclose(fptmp);
  481. XX
  482. XX    status = unlink(fname);
  483. XX    if (status != 0) {
  484. XX        printf("Can't remove file - %s", fname);
  485. XX        exit(1);
  486. XX    }
  487. XX
  488. XX    if (printed) {
  489. XX        if ((fp = fopen(fname,"w")) == NULL) {
  490. XX            print_open_error_exit(fname);
  491. XX        }
  492. XX
  493. XX        if ((fptmp = fopen(rstmp,"r")) == NULL) {
  494. XX            print_open_error_exit(rstmp);
  495. XX        }
  496. XX
  497. XX        while (fgets(s, MAXLEN, fptmp) != NULL) {
  498. XX            fputs(s, fp);
  499. XX        }
  500. XX    }
  501. XX
  502. XX    fclose(fp);
  503. XX    fclose(fptmp);
  504. XX    status = unlink(rstmp);
  505. XX
  506. XX    if (deleted)
  507. XX        printf("%d %s deleted.\n", deleted, entity );
  508. XX
  509. XX    if ( (ddisplay && rem_work) || (Ddisplay && !rem_work) )
  510. XX        print_reminders();
  511. XX}
  512. XX
  513. XX
  514. XX/* PRINT REMINDERS/NOTES/ALTERNATES */
  515. XX/* This routine will print reminders/notes/alternates */
  516. XX/* print_line is called to do the printing with */
  517. XX/* auto wrap.  If a search argument was given, only lines that contain the */
  518. XX/* search string will be printed. */
  519. XX
  520. XXprint_reminders()
  521. XX{
  522. XX    register int line_number = 0;
  523. XX
  524. XX    if ((fp = fopen(fname,"r")) == NULL) {
  525. XX        exit(0);
  526. XX    }
  527. XX
  528. XX    if (tcap) {
  529. XX        if (tgetent(buff, getenv("TERM")) == 1) {
  530. XX            tcapok++;
  531. XX            columns = tgetnum("co");
  532. XX            if (columns <= 0)
  533. XX                columns = 80;
  534. XX            columns -= 6;
  535. XX            a = on;
  536. XX            tgetstr(mark_on,  &a);
  537. XX            a = off;
  538. XX            tgetstr(mark_off, &a);
  539. XX            if (!strlen(on)) {
  540. XX                if (tgetflag("bs"))
  541. XX                    strcpy(on, "\010*");
  542. XX                else {
  543. XX                    a = on;
  544. XX                    tgetstr("bc", &a);
  545. XX                }
  546. XX            }
  547. XX        }
  548. XX    }
  549. XX        
  550. XX    printf("\n%s:\n", entity);
  551. XX
  552. XX    while ((len = getline(s, MAXLEN)) > 0) {
  553. XX        if (search) {
  554. XX            if (instr(s, sstr) != -1) {
  555. XX                printf("%3d. ", ++line_number);
  556. XX                if (tcapok)
  557. XX                    find_mark();
  558. XX                if (mark)
  559. XX                    printf("%s", on);
  560. XX                print_line(s, columns);
  561. XX                if (mark) {
  562. XX                    printf("%s", off);
  563. XX                    mark = 0;
  564. XX                }
  565. XX            }
  566. XX            else
  567. XX                line_number++;
  568. XX        }
  569. XX        else {
  570. XX            printf("%3d. ", ++line_number);
  571. XX            if (tcapok)
  572. XX                find_mark();
  573. XX            if (mark)
  574. XX                printf("%s", on);
  575. XX            print_line(s, columns);
  576. XX            if (mark) {
  577. XX                printf("%s", off);
  578. XX                mark = 0;
  579. XX            }
  580. XX        }
  581. XX    }
  582. XX
  583. XX    printf("\n");
  584. XX
  585. XX    fclose(fp);
  586. XX}
  587. XX
  588. XXgetline(s, lim)
  589. XXchar s[];
  590. XXint  lim;
  591. XX{
  592. XX    register int i = 0;
  593. XX    register int c;
  594. XX
  595. XX    while (--lim > 0 && (c=getc(fp)) != EOF && c != '\n')
  596. XX        s[i++] = c;
  597. XX
  598. XX    if (c == '\n')
  599. XX        s[i++] = c;
  600. XX
  601. XX    s[i] = '\0';
  602. XX
  603. XX    return(i);
  604. XX}
  605. XX
  606. XXalldigits(s)
  607. XXregister char *s;
  608. XX{
  609. XX    register c = *s++;
  610. XX
  611. XX    do {
  612. XX    if (!isdigit(c))
  613. XX        return(0);
  614. XX    }
  615. XX    while (c = *s++);
  616. XX
  617. XX    return(1);
  618. XX}
  619. XX
  620. XXinstr(s, t)
  621. XXchar s[], t[];
  622. XX{
  623. XX    register int i, j, k;
  624. XX
  625. XX    for (i = 0; s[i] != '\0' ; i++) {
  626. XX        for (j=i, k=0 ; t[k] != '\0' && s[j]==t[k] ; j++ , k++)
  627. XX            ;
  628. XX        if (t[k] == '\0')
  629. XX            return(i);
  630. XX    }
  631. XX    return(-1);
  632. XX}
  633. XX
  634. XXprint_open_error_exit(file_name)
  635. XXchar    file_name[];
  636. XX{
  637. XX    printf("Can't open file - %s\n",file_name);
  638. XX    exit(1);
  639. XX}
  640. XX
  641. XX/* This routine will wrap lines greater than 75 characters long.      */
  642. XX/* An attempt is made to break the line up after a word.  If a "word" */
  643. XX/* is greater than 75 characters, the word will be split.             */ 
  644. XX/*     pur-ee!mjs                              */
  645. XX
  646. XX#define SPACE    ' '
  647. XXint print_line (line, maxlen)
  648. XXchar    line[];            /* string to be printed */
  649. XXunsigned int    maxlen;        /* longest line permitted for output */
  650. XX{
  651. XX    register int    index,    /* used in for loops */
  652. XX                    breaking_pt,/* index in line[] at point to break line 
  653. XX                */
  654. XX                    nospace = 0,/* set to TRUE if no space is found */
  655. XX                    last_br_pt = 0,/* last breaking point */
  656. XX                    line_len,    /* number of characters in line[] */
  657. XX                    done = 0;    /* set to TRUE if finished */
  658. XX
  659. XX /* if line[] isn't longer than the longest line permitted, we can just
  660. XX    print it, and return. */
  661. XX
  662. XX    line_len = strlen (line);
  663. XX
  664. XX    if (strlen (line) <= maxlen) {
  665. XX    printf ("%s", line);
  666. XX    return;
  667. XX    }
  668. XX
  669. XX    do {
  670. XX    /* set breaking_pt at point in line[] where we should break the line.
  671. XX       Do this by start looking backwards from maxlen until a space is
  672. XX       found. */
  673. XX
  674. XX    for (index = (maxlen + last_br_pt); line[index] != SPACE; --index) {
  675. XX        if (index == last_br_pt) {
  676. XX        nospace = 1;
  677. XX        break;
  678. XX        }
  679. XX        if (index >= line_len) {
  680. XX        index = line_len - 1;   /* 1 gets added to it below */
  681. XX        done = 1;
  682. XX        break;
  683. XX        }
  684. XX    }
  685. XX    breaking_pt = index + 1;
  686. XX
  687. XX    /* if there is no space found, set breaking point to MAXLEN */
  688. XX
  689. XX    if (nospace == 1) {
  690. XX        breaking_pt = maxlen + last_br_pt;
  691. XX        nospace = 0;    /* reset flag */
  692. XX    }
  693. XX    /* print line[] up to breaking point */
  694. XX
  695. XX    for (index = last_br_pt; index < breaking_pt; ++index) 
  696. XX        putchar (line[index]);
  697. XX
  698. XX
  699. XX        if (last_br_pt == 0) /* this is our first time through */
  700. XX            maxlen -= 5; /* for indenting */
  701. XX        if (!done) {
  702. XX        if (mark)
  703. XX            printf("%s", off);
  704. XX
  705. XX            printf("\n     "); /* indent */
  706. XX
  707. XX        if (mark)
  708. XX            printf("%s", on);
  709. XX    }
  710. XX
  711. XX    last_br_pt = breaking_pt;
  712. XX    } while (!done);
  713. XX}
  714. XXfind_mark()
  715. XX{
  716. XX    if (s[len-2] == '\07') {
  717. XX        mark = 1;
  718. XX        s[len-2] = '\n';
  719. XX        s[len-1] = '\0';
  720. XX    }
  721. XX}
  722. SHAR_EOF
  723. if test 13652 -ne "`wc -c < 'rs.c'`"
  724. then
  725.     echo shar: "error transmitting 'rs.c'" '(should have been 13652 characters)'
  726. fi
  727. fi
  728. echo shar: "extracting 'rs.1'" '(5288 characters)'
  729. if test -f 'rs.1'
  730. then
  731.     echo shar: "will not over-write existing file 'rs.1'"
  732. else
  733. sed 's/^XX//' << \SHAR_EOF > 'rs.1'
  734. XX.TH RS 1 "3 July 1986"
  735. XX.ad b
  736. XX.SH NAME
  737. XXrs \- reminder system
  738. XX.SH SYNOPSIS
  739. XX.B rs
  740. XX[
  741. XX.B \-Aacknpv
  742. XX] [
  743. XX.B \-s
  744. XX.I string
  745. XX] [
  746. XX.BI \-d \0# \0#-#
  747. XX]
  748. XX.SH DESCRIPTION
  749. XX.I rs
  750. XXis a personal reminder system.
  751. XXReminders can be displayed every time you log into the system
  752. XXby placing the
  753. XX.I rs
  754. XXcommand in your
  755. XX.I .login
  756. XXor
  757. XX.I .profile
  758. XXfile.
  759. XXThe reminder system includes three reminder files:
  760. XX.nf
  761. XX
  762. XX
  763. XX    1.    Reminders  ($HOME/.reminders)
  764. XX    2.    Notes      ($HOME/.rsnotes)
  765. XX    3.    User defined by setting the RSALT environment variable.
  766. XX        (Defaults to $HOME/.phone_numbers)
  767. XX.fi
  768. XX.PP
  769. XX.I Options:
  770. XX.TP
  771. XX.I rs
  772. XXWith no options, print reminder list to terminal.
  773. XX.TP
  774. XX.B \-A
  775. XXWork with
  776. XX.I alternate
  777. XXreminder file.
  778. XXThe name of the alternate file is user defined by setting the
  779. XX.I RSALT
  780. XXenvironment variable.  (If
  781. XX.I RSALT
  782. XXis not set, the alternate file defaults to 'phone_numbers'.)
  783. XX.TP
  784. XX.B \-a
  785. XXAdd reminders/notes/alternates.
  786. XXYou are prompted to add reminders/notes/alternates.  Appending a ^G (Control-G)
  787. XXat the end of a reminder will cause rs to mark it (Highlight) during display.  (See
  788. XX.I RSINIT
  789. XXbelow.)
  790. XX.TP
  791. XX.B \-c
  792. XXAdd entries to calendar system.  You are prompted to add calendar entries.
  793. XXSee
  794. XX.I calendar(1).
  795. XX.TP
  796. XX.B \-d
  797. XXDelete reminders/notes/alternates.  This option, followed by a number or
  798. XXnumbers, causes
  799. XX.I rs
  800. XXto delete the specified reminders/notes/alternates.
  801. XXMore than one number may be placed on the same command line separated by
  802. XXblanks.
  803. XXA range of numbers may also be specified.
  804. XX.TP
  805. XX.B \-e
  806. XXEdit reminders/notes/alternates file.  If the EDITOR environment variable is
  807. XXset, the specified EDITOR is used.  If not, vi is used by default. (-v may be
  808. XXused in place of -e)
  809. XX.TP
  810. XX.B \-k
  811. XXKill (delete) all reminders/notes/alternates.
  812. XX.TP
  813. XX.B \-n
  814. XXWork on
  815. XX.I notes
  816. XXfile.
  817. XX.TP
  818. XX.B \-p
  819. XXPrint reminders/notes/alternates.
  820. XX(By default, does an
  821. XX.I lpr
  822. XXof reminder file.)
  823. XX.TP
  824. XX.B \-s
  825. XXSearch for reminders/notes/alternates that match the given string.
  826. XX.PP
  827. XXMore than one option may follow a single "\-", for example:
  828. XX.nf
  829. XX.RS
  830. XX
  831. XXrs -na    The command for "add note."
  832. XX.RE
  833. XX.fi
  834. XX.PP
  835. XX.SH NOTES
  836. XXTo mark a reminder (Highlight), append a ^G (Control-G) to the reminder.
  837. XX.I rs
  838. XXwill mark the reminder during display using one of the following:
  839. XX.nf
  840. XX
  841. XX
  842. XX    Standout
  843. XX    Underscore.
  844. XX    Bold
  845. XX    Asterisk
  846. XX
  847. XX.fi
  848. XXas defined in
  849. XX.I RSINIT.
  850. XX.PP
  851. XX.I rs
  852. XXlooks in the environment variable
  853. XX.I RSINIT
  854. XXfor additional configuration options.  Options are:
  855. XX.nf
  856. XX
  857. XX
  858. XXA    Display notes/alternates/calendar after additions.
  859. XXD    Display notes/alternates/calendar after deletions.
  860. XXa    Display reminders after additions.
  861. XXd    Display reminders after deletions.
  862. XXI    Ignore TERMCAP info during startup.
  863. XX    (Default number of columns is 80, no mark capability)
  864. XX
  865. XXDefault mark is standout mode.
  866. XX    ('so' and 'se' must be defined in termcap entry.)
  867. XX
  868. XXU    Use underscore (underline) to mark reminders.
  869. XX    ('us' and 'ue' must be defined in termcap entry.)
  870. XXB    Use Bold to mark reminders.
  871. XX    ('bo' and 'be' must be defined in termcap entry.)
  872. XXS    Use '*' to mark reminders.
  873. XX    (Terminal must have 'bs'.)
  874. XX.fi
  875. XX.PP
  876. XXFor example,
  877. XXif you prefer to view your reminders/notes/alternates after
  878. XXadditions/deletions, the
  879. XX.I csh
  880. XXcommand:
  881. XX.nf
  882. XX
  883. XX
  884. XX          setenv RSINIT 'aAdD'
  885. XX
  886. XX.fi
  887. XXcauses
  888. XX.I rs
  889. XXto display your reminders/notes/alternates after additions/deletions.
  890. XXThe above command sequence may be placed in your
  891. XX.I .login
  892. XXfile.
  893. XX.PP
  894. XXReminders/notes/alternates may be from one to 255 characters long.
  895. XXIf a reminder is longer than one line (As defined in termcap 'co'),
  896. XX.I rs
  897. XXdoes automatic word wrap.
  898. XXTo add a reminder/note/alternate longer than one line,
  899. XXtype in the entire reminder/note/alternate and end with a single carriage
  900. XXreturn.
  901. XXDo
  902. XX.B not
  903. XXinsert carriage returns before the end of a reminder/note/alternate.
  904. XXA single carriage return
  905. XX.B always
  906. XXindicates the
  907. XX.B end
  908. XXof a reminder.
  909. XX.SH EXAMPLES
  910. XX.TP
  911. XXrs -d 1 5 8
  912. XXDelete reminders 1, 5, 8.
  913. XX.TP
  914. XXrs -n -d 1-5 8
  915. XXDelete notes 1, 2, 3, 4, 5, 8.
  916. XX.TP
  917. XXrs -k
  918. XXKill all reminders.
  919. XX.SH EXAMPLE USE OF ALTERNATE REMINDER FILE
  920. XX.PP
  921. XXIf you would like to have a list of phone numbers that can be accessed by the
  922. XXreminder system, you can do the following:
  923. XX.PP
  924. XXSet the
  925. XX.I RSALT
  926. XXenvironment variable to
  927. XX.I phone-numbers
  928. XXby including the following command line in your
  929. XX.I .login
  930. XXfile:
  931. XX.TP
  932. XX.I "     setenv RSALT 'phone-numbers'"
  933. XX.TP
  934. XXUse the reminder system command:
  935. XX.TP
  936. XX.I "     rs -A [options]"
  937. XX.TP
  938. XXto work on the phone-numbers reminder file.
  939. XX.SH EXAMPLE COMMANDS FOR PHONE-NUMBERS REMINDER FILE
  940. XX.TP
  941. XXrs \-A \-a
  942. XXAdd phone numbers to the phone-numbers reminder file.
  943. XX.TP
  944. XXrs \-A \-s Joslyn
  945. XXSearch for Joslyn's phone number.
  946. XX.TP
  947. XXrs \-A \-e
  948. XXEdit phone-numbers.
  949. XX.TP
  950. XXrs \-A \-p
  951. XXPrint phone-numbers on the line printer.
  952. XX.TP
  953. XXrs \-A \-d 1
  954. XXDelete the first line from phone-numbers.
  955. XX.SH TIPS
  956. XXTo make use of the notes/alternates easier, the author defines two aliases:
  957. XX.nf
  958. XX
  959. XXalias rsn 'rs -n'     Use rsn to work with notes file.
  960. XXalias rsa 'rs -A'     Use rsa to work with alternate file.
  961. XX.fi
  962. XX.SH FILES
  963. XX.nf
  964. XX
  965. XX$HOME/.reminders    User's reminders.
  966. XX$HOME/.rsnotes      User's notes.
  967. XX/tmp/.rs*           Used during reminder deletion.
  968. XX$HOME/.?            Other reminder file(s) defined by RSALT.
  969. XX.fi
  970. XX.SH SEE ALSO
  971. XXcalendar(1), csh(1), environ(7), lpr(1), vi(1)
  972. XX.SH AUTHOR
  973. XX.nf
  974. XXDon Joslyn, Manager
  975. XXNova University Computer Center
  976. XX3301 College Avenue
  977. XXFort Lauderdale, Florida 33314
  978. XX(305) 475-7678
  979. XX{codas, allegra, ucf-cs}!novavax!don
  980. XX.fi
  981. SHAR_EOF
  982. if test 5288 -ne "`wc -c < 'rs.1'`"
  983. then
  984.     echo shar: "error transmitting 'rs.1'" '(should have been 5288 characters)'
  985. fi
  986. fi
  987. exit 0
  988. #    End of shell archive
  989.